package com.zzx.config;

import com.zzx.bean.Person;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * config
 *
 * @author Jesse
 * @version 1.0
 * @date 2021/06/12
 */
@Configuration
//@ComponentScan("com.zzx")
// @ComponentScan value:指定要扫描的包
// excludeFilters = Filter[]:指定扫描的时候按照什么规则排除哪些组件
// includeFilters = Filter[]:指定扫描的时候只需要包含哪些组件
//@ComponentScan(value = "com.zzx",useDefaultFilters = false, includeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
//})
//@ComponentScan(value = "com.zzx", excludeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
//})
@ComponentScans(value = {
        @ComponentScan(value = "com.zzx", excludeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
        }),
        @ComponentScan(value = "com.zzx", useDefaultFilters = false, includeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
        })
})
public class MainConfig {

    // 给容器中注册一个 bean，类型为返回值类型，id 默认是方法名作为 id
    // 可以在 @Bean 中设置 bean 的名称
    @Bean("person")
    public Person getPerson() {
        return new Person("zzx", 28);
    }
}
